package com.gavel.utils;

import com.gavel.database.SQLExecutor;
import com.mrobuy.jdvc.entity.HtmlCache;
import com.mrobuy.util.MD5Utils;

public class HtmlLoder {


    public static String load(String url) {

        if (StringUtils.isBlank(url)) {
            return "";
        }

        String id = MD5Utils.md5Hex(url);
        String suffix =  id.substring(id.length()-1);


        HtmlCache htmlCache = null;
        try {
            htmlCache = SQLExecutor.executeQueryBean("select * from htmlcache_" + StringUtils.trim(suffix) + "  where ID = ? ", HtmlCache.class, id);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if ( htmlCache==null || htmlCache.getHtml()==null ) {
            return null;
        }

        return  htmlCache.getHtml();
    }

}
